import React, { createContext, useContext } from "react";
import { useBountyMock } from "./useBountyMock";

const BountyContext = createContext(null);

export const BountyProvider = ({ children }) => {
  const bountyMock = useBountyMock();
  return (
      <BountyContext.Provider value={bountyMock}>
        {children}
      </BountyContext.Provider>
  );
};

export const useBounty = () => {
  const context = useContext(BountyContext);
  if (!context) {
    throw new Error("useBounty必须在BountyProvider内部使用");
  }
  return context;
};